<!DOCTYPE html>
<html lang="zh">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <script src="https://cdn.staticfile.org/jquery/3.5.1/jquery.min.js"></script>
    <title>登录页示例</title>
</head>

<body>

    <style>
        * {
            text-align: center;
        }

        body {
            /* background: #263238; */
            width: 100vw;
            height: 100vh;
            margin: 0;
            padding: 0;
        }

        .margin-v {
            margin-top: 8px;
            margin-bottom: 8px;
        }

        @keyframes frams {
            0% {
                background: url("./img/1.jpg") no-repeat center center;
            }

            33% {
                background: url("./img/2.jpg") no-repeat center center;
            }

            66% {
                background: url("./img/3.jpg") no-repeat center center;
            }

            100% {
                background: url("./img/1.jpg") no-repeat center center;
            }
        }

        .line-layout {
            width: inherit;
            height: inherit;
            position: fixed;
            display: flex;
            flex-direction: column;
            justify-content: center;
            align-items: center;
            animation:frams 20s infinite;
        }

        .line-layout-st {
            flex-direction: column;
            justify-content: start;
            align-items: center;
        }

        .viewbox {
            display: block;
            width: 350px;
            height: 280px;
            background: #263238;
            border-radius: 16px;
            opacity: 0.85;
            backdrop-filter: blur(5px);
            box-shadow: rgba(5, 5, 5, 0.5) 5px 3px 10px;
        }

        .line-item {
            /* margin-top: 2px; */
            margin-bottom: 20px;
        }

        input.input-box {
            text-align: start;
            width: 260px;
            height: 32px;
            line-height: 1.2;
            padding-left: 10px;
            border-radius: 5px;
            border: #3f4c51 solid 2px;
            color: #bdcada;
            outline: none;
            transition: all ease-in-out 0.2s;
            background-color: #323e44;
        }

        input.input-box:-internal-autofill-previewed,
        input.input-box:-internal-autofill-selected {
            -webkit-text-fill-color: #FFFFFF !important;
            transition: background-color 5000s ease-in-out 0s !important;
        }

        input.input-box::-webkit-input-placeholder {
            /* WebKit browsers 适配谷歌 */
            color: #bdcada;
        }

        input.input-box:-moz-placeholder {
            /* Mozilla Firefox 4 to 18 适配火狐 */
            color: #bdcada;
        }

        input.input-box::-moz-placeholder {
            /* Mozilla Firefox 19+ 适配火狐 */
            color: #bdcada;
        }

        input.input-box:-ms-input-placeholder {
            /* Internet Explorer 10+  适配ie*/
            color: #bdcada;
        }

        input.input-box:focus {
            border: #64ffda solid 2px;
        }

        input.submit-btn {
            /* width: 260px; */
            width: 150px;
            height: 32px;
            line-height: 1.2;
            border-radius: 5px;
            /* border: #3f4c51 solid 2px; */
            outline: none;
            transition: all ease-in-out 0.2s;
            background: #7e9868;
            border: none;
            color: #ffffff;
            font-size: 20px;
            font-weight: 500;
            cursor: pointer;
        }

        input.submit-btn:hover {
            background: #a2c076;
        }

        input.submit-btn:active {
            background: #c3e88d;
        }

        .title-text {
            color: #7abfbb;
        }

        .iforget {
            margin-top: 0px;
            color: #3f4c51;
            text-decoration: none;
            transition: all ease-in-out 0.2s;
        }

        .iforget:hover {
            color: #7abfbb;
        }

        .iforget:active {
            color: #64ffda;
        }

        footer span {
            color: #888888;
            transition: all ease-in-out 0.5s;
            cursor: default;
        }

        footer span:hover {
            color: #ffffff;
        }
    </style>
    <div class="line-layout">
        <div class="viewbox">
            <div class="line-layout-st margin-v">
                <h2 class="title-text">登录</h2>
                <form>
                    <div class="line-item">
                        <input type="text" placeholder="账户名" name="username" class="input-box" />
                    </div>
                    <div class="line-item">
                        <input type="password" placeholder="密码" name="password" class="input-box" />
                    </div>
                    <div class="line-item">
                        <input type="submit" value="登录" class="submit-btn" />
                    </div>
                </form>
                <a href="javascript:void(0);" onclick="window.open('./index.html')" class="iforget"
                    title="忘记密码点此重置">忘记密码</a>
            </div>
        </div>
        <footer class="margin-v">
            <span>lnp 2020. MIT LICENSE</span>
        </footer>
    </div>

    <script>
        $('input[name="username"]').on('change', () => {
            if ($('input[name="username"]').val().length < 3) {
                alert('用户名过短!');
                $('input[name="username"]').css('border', '#ff4852 solid 2px');
            } else {
                $('input[name="username"]').removeAttr('style');
            }
        });

        $('input[name="password"]').on('change', () => {
            if ($('input[name="password"]').val().length < 4) {
                alert('密码过短!');
                $('input[name="password"]').css('border', '#ff4852 solid 2px');
            } else {
                $('input[name="password"]').removeAttr('style');
            }
        });

        $('form').submit(() => {
            let json = {
                username: $('input[name="username"]').val(),
                password: $('input[name="password"]').val()
            };
            if (json.username.length < 3) {
                alert('用户名过短!');
                $('input[name="username"]').css('border', '#ff4852 solid 2px');
                return false;
            }
            if (json.password.length < 4) {
                alert('密码过短!');
                $('input[name="password"]').css('border', '#ff4852 solid 2px');
                return false;
            }
            console.log(json);
            $.ajax({
                url: './login.html',
                data: json,
                dataType: 'text',
                type: 'post',
                success: (data) => {

                }
            });
            return false;
        });
    </script>

</body>

</html>